package com.yingxin.yx.framework.commons.help;

import com.yingxin.yx.framework.commons.enums.MaterialType;

import java.util.HashMap;
import java.util.Map;

public class MaterialTypeHelper {

    private static final Map<String, MaterialType> map = new HashMap<>();

    public static void init() {
        if (map.size() == 0) {
            for (MaterialType type : MaterialType.values()) {
                map.put(type.getType(), type);
            }
        }
    }

    public static String getName(String id) {
        init();
        MaterialType type = map.get(id);
        if (type != null) {
            return type.getTypeName();
        }
        return null;
    }

    public static MaterialType get(String id) {
        init();
        return map.get(id);
    }

}
